home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
e
/
megsplit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-09
|
507b
|
33 lines
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/* spit a file (stdin) into 2meg chunks */
#define twomeg (2*1024*1024)
char rbuf[twomeg];
main(int argc, char *argv[])
{
int rcount;
int nreads = 0;
char f2name[100];
int fd2;
while ((rcount = read(0,rbuf,twomeg))>0)
{
sprintf(f2name,"%s.%d",argv[1],nreads);
fd2 = creat(f2name,0644);
if (write(fd2,rbuf,rcount)<rcount)
{
perror("write failed");
exit();
}
nreads++;
}
if (rcount<0)
perror("read failed");
}